package com.huadao.cart_ccs.experiment.home;

import com.huadao.cart_ccs.base.BaseHttpPresenter;
import com.huadao.cart_ccs.base.BasePresenter;
import com.huadao.cart_ccs.base.BaseView;
import com.huadao.cart_ccs.data.bean.EnvironmentLog;
import com.huadao.cart_ccs.data.bo.ExperimentStage;
import com.huadao.cart_ccs.data.task.ChangeLiquidBO;
import com.huadao.cart_ccs.data.task.ChangeLiquidTask;
import com.huadao.cart_ccs.data.task.CleanPipesTask;
import com.huadao.cart_ccs.data.task.LiquidLoopTask;
import com.huadao.cart_ccs.greendao.entity.DeviceRecord;
import com.huadao.cart_ccs.greendao.entity.Injection;
import com.huadao.cart_ccs.greendao.entity.Operation;
import com.huadao.cart_ccs.greendao.entity.Sample;

import java.util.Date;

public interface ExperimentContract {
    interface IExperimentView extends BaseView {
        void onOpenFluidIntakePumpSucc(int speed);
        void onCloseFluidIntakePumpSucc();
        void onOpenWastePumpSucc(int speed);
        void onCloseWastePumpSucc();
        void onOpenCirclePumpSucc(int speed);
        void onCloseCirclePumpSucc();
        void onOpenReclaimPumpSucc(int speed);
        void onCloseReclaimPumpSucc();
        void onOpenStirrerSucc(int speed);
        void onCloseStirrerSucc();
        void onOpenUltravioletLightSucc();
        void onCloseUltravioletLightSucc();
        void onReceiveCO2(double CO2);
        void onReceiveO2(double O2);
        void onReceiveTemperature(double temperature);
        void onSetCO2(double CO2);
        void onSetO2(double O2);
        void onSetTemperature(double temperature);
        void liquidLevelWarning();
        void liquidLevelOk();
        void moveToStage(ExperimentStage experimentStage);
        void onOpenCultureTankSucc(int speed);
        void onCloseCultureTankSucc();
        void onOpenIncubatorSucc();
        void onCloseIncubatorSucc();
        void onError(String err);

        void onStartCultureSucc();
        void onPauseCultureSucc();
        void onResumeCultureSucc();

        void peelSucc(byte[] ad);
        void weightSucc(double weight);
        void weightAfterDischarge(int flow, double weight);
        void finishFluidIntaken();
        void finishCollect();
        void finishDischarge();

        void onStartNewProject();

        void showDialogMessage(String msg);

        void onDoorOpen();
        void onDoorColse();
        void onReadDoor(String statusStr);
        void onDoorStop();

        void peelFail();

        void weightFail();

        void setPorgress1(int progress);
        void setPorgress1Max(int max);
        int getProgress1();
        int getProgress1Max();
        void setPorgress1Visibility(int visibility);

        void setPorgress2(int progress);
        void setPorgress2Max(int max);
        int getProgress2();
        int getProgress2Max();
        void setPorgress2Visibility(int visibility);

        void setPorgress3(int progress);
        void setPorgress3Max(int max);
        int getProgress3();
        int getProgress3Max();
        void setPorgress3Visibility(int visibility);

        void setPorgress4(int progress);
        void setPorgress4Max(int max);
        int getProgress4();
        int getProgress4Max();
        void setPorgress4Visibility(int visibility);

        void clearAllProgress();

        void setFluidIntakeCountDown(int count);
        void setDischargeCountDown(int count);
        void setCollectCountDown(int count);
        void setChangeCountDown(int count);

        void onChangeLiquidSucc();

        void onFluidIntakePumpAlarm(String alarmStr);
        void onFluidIntakePumpAlarmDismiss(int speed);
        void onWastePumpAlarm(String alarmStr);
        void onWastePumpAlarmDismiss(int speed);
        void onCirclingPumpAlarm(String alarmStr);
        void onCirclingPumpAlarmDismiss(int speed);
        void onReclaimPumpAlarm(String alarmStr);
        void onReclaimPumpAlarmDismiss(int speed);

        void onReadFluidIntake(byte direction, int speed, String alarmStr);
        void onReadWaste(byte direction, int speed, String alarmStr);
        void onReadCircling(byte direction, int speed, String alarmStr);
        void onReadReclaim(byte direction, int speed, String alarmStr);

        void onInitCultureLiquidFinish();
        void cleanPipefinishOne(String taskName);
        void cleanPipefinishAll(String taskName);

        void runOnUi(Runnable runnable);

        void onSalineOpen();
        void onSalineClose();
        void onMediumOpen();
        void onMediumClose();
        void onShakerOpen();
        void onShakerClose();

        void onRequestOpenProject();

        void onSourFinish();

        void onRequestFinishReclaim();

        void onRequestEnvironmentLog(EnvironmentLog data);

        void onWeightFailed();

        void startFluidInputProgressBar();
        void pauseFluidInputProgressBar();
        void resumeFluidInputProgressBar();
        void setFluidInputProgressBar(int max);
        void adjustFluidInputProgressBar(int increase);
        void stopFluidInputProgressBar();
        void startDischargeProgressBar();
        void pauseDischargeProgressBar();
        void resumeDischargeProgressBar();
        void setDischargeProgressBar(int max);
        void adjustDischargeProgressBar(int increase);
        void stoptDischargeProgressBar();
        void startCollectProgressBar();
        void pauseCollectProgressBar();
        void resumeCollectProgressBar();
        void setCollectProgressBar(int max);
        void adjustCollectProgressBar(int increase);
        void stopCollectProgressBar();
        void startChangeLiquidProgressBar();
        void pauseChangeLiquidProgressBar();
        void resumeChangeLiquidProgressBar();
        void setChangeLiquidProgressBar(int max);
        void adjustChangeLiquidProgressBar(int increase);
        void stopChangeLiquidProgressBar();
        void startCleanPipeProgressBar();
        void pauseCleanPipeProgressBar();
        void resumeCleanPipeProgressBar();
        void setCleanPipeProgressBar(int max);
        void adjustCleanPipeProgressBar(int increase);
        void stopCleanPipeProgressBar();

        void finishFluidIntakenCell();
        void finishFluidIntakenViruses();
        void finishFluidIntakenCryoprotectant();

        void readCO2Failed();
        void readO2Failed();
        void readTemperatureFailed();

        void setO2Failed();
        void setTemperatureFailed();
        void setCO2Failed();

        void onTerminateFluidIntaken();
        void onTerminateDischarge();
        void onTerminateCollect();
        void onTerminateCleanPipe();
        void onTerminateChangeLiquid();
    }

    abstract class IExperimentPresenter extends BaseHttpPresenter<IExperimentView> {

        abstract void scheduleReadCO2();
        abstract void scheduleReadO2();
        abstract void scheduleReadTemperature();
        abstract void scheduleWeight();
        abstract void activateLiquidLevelAlarm();
        abstract void stopScheduleReadCO2();
        abstract void stopScheduleReadO2();
        abstract void stopScheduleReadTemperature();
        abstract void stopScheduleWeight();
        abstract void stopActivateLiquidLevelAlarm();
        abstract String checkCultureEnvironment();
        abstract void fluidIntake(int amount,int speed,int liquidType,String operator, Date date,Operation operation);
        abstract void discharge(int amount,int speed,String operator, Date date,Operation operation);
        abstract void collect(int amount,int speed,String operator, Date date,Operation operation,String collectName);
        abstract void changeLiquid(int amount,int fluidIntakeSpeed,int wasteSpeed,int liquidType,Operation operation);
        abstract void changeLiquid(ChangeLiquidBO changeLiquidBO,Date operateDate,String operator);
        abstract void editChangeLiquid(ChangeLiquidBO changeLiquidBO);
        abstract String checkFluidIntake();
        abstract String checkDischarge();
        abstract String checkCollect();
        abstract String checkChangeLiquid();
        abstract boolean isChangingLiquid();

        //每过24小时后进入下个阶段,直到进入最后一个阶段
        public abstract void scheduleExperimentStage();

        public abstract void scheduleChangeAir(int delay);
        public abstract void cancelScheduleChangeAir();

        abstract void scourAfterInjection();

        abstract void openPumpTask(byte modularNO, int speed, byte direction, Operation operation);
        abstract void closePumpTask(byte modularNO,Operation operation);
        abstract void openStirrerTask(int speed,DeviceRecord deviceRecord);
        abstract void closeStirrerTask(DeviceRecord deviceRecord);
        abstract void openUltravioletLightTask();
        abstract void closeUltravioletLightTask();
        abstract void openCultureTankTask(int speed,DeviceRecord deviceRecord);
        abstract void closeCultureTankTask(DeviceRecord deviceRecord);
        abstract void openIncubatorTask();
        abstract void closeIncubatorTask();

        abstract void setCO2(double co2);
        abstract void setO2(double o2);
        abstract void setTemperature(double temperature);

        abstract void peel(byte[] ad);
        abstract void weight();

        abstract int getCurrentLiquidInTank();

        public abstract void saveInjectionData(Injection injection);
        public abstract void saveSampleData(Sample sample);
        public abstract void saveOperation(Operation operation);

//        abstract boolean checkTaskBeforeClose(byte modularNO);
        abstract void onLiquidLevelError();

//        abstract void pauseCulture();
//        abstract void resumeCulture();

        abstract boolean isPumpStoped(byte ModularNo);
        abstract boolean isPumpPaused(byte ModularNo);
        abstract boolean isPumpRunned(byte ModularNo);
//
        abstract int getFluidIntakenPumpSpeed();

        abstract void startNewProject();

        abstract void openDoor();
        abstract void closeDoor();
        public abstract void readDoor();
        public abstract void stopDoor();

        abstract void moveToCorrectStage();

        public abstract void ReadTemperature();
        public abstract void ReadO2();
        public abstract void ReadCO2();

        public abstract boolean isScheduleTaskClose();

        public abstract double getLeftTime(byte modularNO);

        public abstract void editAmountForPausedTask(byte modularNO, int amount);

        public abstract void setIsTesting(boolean isTesting);

        public abstract void activeDetectPumpFluidIntak();
        public abstract void activeDetectPumpWaste();
        public abstract void activeDetectPumpCircling();
        public abstract void activeDetectPumpReclaim();
        public abstract void deActiveDetectPumpFluidIntak();
        public abstract void deActiveDetectPumpWaste();
        public abstract void deActiveDetectPumpCircling();
        public abstract void deActiveDetectPumpReclaim();

        public abstract int getFluidIntakenStatus();
        public abstract int getWasteStatus();
        public abstract int getCirclingStatus();
        public abstract int getReclaimStatus();
        public abstract int getChangeLiquidStatus();

        public abstract void closeHeat();
        public abstract void closeCO2();
        public abstract void closeO2();

        public abstract void setEnvironment();

        public abstract void initCultureLiquid(int amount);

        public abstract void saveDeviceRecord(DeviceRecord deviceRecord);

        public abstract void cleanPipes(String taskName,int fluidAmount,int wasteAmount,int cleanNumbers,int loopTime,int fluidSpeed,int circlingSpeed,int wasteSpeed);

        public abstract void scheduleLiquidPlan();

        //对操作前进行检查，是否可以进行改操作
        public abstract String checkBeforeFluidIntake();

        public abstract String checkBeforeDischage();

        public abstract String checkBeforeCollect();

        public abstract String checkBeforeChangeLiquid();

        public abstract String checkBeforeCleanPipes();

        public abstract String checkBeforeSample();

        public abstract String checkBeforeInject();

        public abstract void stopAllTask();

        public abstract void terminateFluidIntake();

        public abstract void terminateDischarge();

        public abstract void terminateCircle();

        public abstract void terminateCollect();

        public abstract void terminateChangeLiquid();

        public abstract void terminateCleanPipe();

        public abstract ChangeLiquidBO getChangeLiquidBO();

        public abstract boolean isReadyForInject();

        public abstract boolean isReadyForSample();

        public abstract void openSalineValve();

        public abstract void closeSalineValve();

        public abstract void openMediumValve();

        public abstract void closeMediumValve();

        public abstract void changeLiquidWithSaline();

        public abstract void addCryoprotectant();

        public abstract void recoverAD();

        public abstract void requestOpenProject();

        public abstract void scheduleRequestEnvironmentParams();

        public abstract void requestFinishReclaim();

        public abstract void stopAllOperate();

        public abstract void requestOperationLog(String behavior, String note);

        public abstract CleanPipesTask getCleanPipeTask();

        public abstract LiquidLoopTask getFluidIntakenTask();

        public abstract LiquidLoopTask getDischargeTask();

        public abstract LiquidLoopTask getCollectTask();

        public abstract ChangeLiquidTask getChangeLiquidTask();

        public abstract void startShakeTable();

        public abstract void stopShakeTable();
    }
}
